package com.work.formaldehyde.activityadapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.work.formaldehyde.R;
import com.work.formaldehyde.model.GetAddressModel;

import java.util.ArrayList;

public class DiZhiAdapter extends BaseAdapter {
    ArrayList<String> list;
    ArrayList<GetAddressModel.data> lists;
    Context context;

    public DiZhiAdapter(ArrayList<String> list,
                        ArrayList<GetAddressModel.data> lists, Context context) {
        // TODO Auto-generated constructor stub
        this.list = list;
        this.lists = lists;
        this.context = context;
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return lists != null ? lists.size() : 0;
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return lists != null ? lists.get(position) : 0;
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        convertView = LayoutInflater.from(context).inflate(R.layout.dizhi_list_item, null);
        init i = new init();
        i.user_name = convertView.findViewById(R.id.user_name);
        i.adds = convertView.findViewById(R.id.adds);
        i.add_check = convertView.findViewById(R.id.add_check);
        if (list.get(position).equals("2")) {
            i.add_check.setImageResource(R.mipmap.addc);
        }
        i.user_name.setText(lists.get(position).getConsignee_name());
        i.adds.setText(lists.get(position).getConsignee_addr());
        convertView.setTag(i);
        return convertView;
    }

    public static class init {
        //首页list的子控件
        TextView user_name, adds;
        ImageView add_check;
    }
}

